import request from '../request'
import qs from 'qs'

export default {
    /**
     *  向后端传递请求参数是json,通过qs转换为参数格式,后端不需要@RequestBody注解接收参数
     */
    list(json) {
        return request({
            url: "carsystem/sysRole/roleList",
            method: "post",
            data: qs.stringify(json),
        });
    },
    tree() {
        return request({
            url: "carsystem/menu/tree",
            method: "get",
            data: null,
        });
    },
    menuTree() {
        return request({
            url: "carsystem/menu/menuTree",
            method: "get",
            data: null,
        });
    },
    listByRoleId(id) {
        return request({
            url: "carsystem/menuRole/listByRoleId?roleId="+id,
            method: "get",
            data: null,
        });
    },
    save(json) {
        return request({
            url: "carsystem/sysRole/roleSave",
            method: "post",
            data: qs.stringify(json),
        });
    },
    update(json) {
        return request({
            url: "carsystem/sysRole/roleUpdate",
            method: "post",
            data: qs.stringify(json),
        });
    },
    listById(id) {
        return request({
            url: "carsystem/sysRole/listById?id="+id,
            method: "post",
            data: null,
        });
    },
    del(id) {
        return request({
            url: "carsystem/sysRole/roleDels?id="+id,
            method: "post",
            data: null,
        });
    },
    pdf() {
        return request({
            url: "http://localhost:9999/sysRole/rolePdf",
            method: "post",
            data: null,
        });
    },
    /**
     *  向后端传递一个参数,用qs转换为参数格式,后端普通变量接收
     */
    test(id) {
        return request({
            url: "/url",
            method: "post",
            data: qs.stringify({id: id}),
        });
    }
}